list= [
    {"name": "电脑", "price": 1999},
    {"name": "鼠标", "price": 10},
    {"name": "游艇", "price": 20},
    {"name": "显卡", "price": 998}
]
# k=1
# for i in goods:
#     print(k,i['name'],i['price'])
#     k+=1
# for m in range(len(goods)):
#     print(m+1,goods[m]['name'],goods[m]['price'])
#
while 1:
    print('-' * 10, '商品列表', '-' * 10)
    for y, u in enumerate(list):

        print('{}\t{}\t{}\t'.format(y+1,u['name'],u['price']))
    choose = input('请输入商品编号：').strip()
    if choose.isdecimal():
        choose = int(choose)
        if 0<choose <len(list):
            print('你要买的商品是{},价格是{}'.format(list[choose-1]['name'],list[choose-1]['price']))
        else:
            print('你输入的商品未找到，请检查后重新输入！')
    elif choose.upper() =='Q':
        print('谢谢惠顾，再见！')
        break
    else:
        print('你输入的信息不能理解，请重新输入')
